﻿var viewModel = new DataMorph.PageViewModel("../api/");

viewModel.Initialize();

ko.applyBindings(viewModel);

$(function() {
    var notifications = $.connection('../generator');
    var localVievModel = viewModel;
    notifications.received(function(data) {
        localVievModel.ProgressValue(data.Progress);
        localVievModel.ProgressMessage(data.Message);
        if (data.Progress == 100) {
            localVievModel.GeneratingData(false);
            localVievModel.ProcessingData(false);
            localVievModel.Notification("");
            localVievModel.Refresh();
        }
    });

    notifications.start().done(function() {
        viewModel.ClientId(notifications.id);
    });
});